
#include "mainscene.h"
#include "ui_mainscene.h"
#include<QIcon>
#include<QPainter>
MainScene::MainScene(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MainScene)
{
    ui->setupUi(this);

    //设置游戏图标
    this->setWindowIcon(QIcon(":/Bird/download.ico"));

    //鸟的对象
    this->m_Bird=new Bird;

    //将设定好的鸟的对象放置在窗口上
    this->m_Bird->setParent(this);
    //设置窗口尺寸
    this->setFixedSize(this->m_Bird->width(),this->m_Bird->height());

    //主场景中启动定时器
    this->m_Bird->running();

    //监听切图的信号
    connect(this->m_Bird,&Bird::changePix,[=](){
        update();//切图了，重新绘画
    });
}

void MainScene::paintEvent(QPaintEvent*)
{
    QPainter painter(this);
    painter.drawPixmap(0,0,this->m_Bird->m_Bird_Pix);
}

MainScene::~MainScene()
{
    delete ui;
}


